﻿using My.SequentialId.SequentialId;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Auditing;
using Volo.Abp.Domain.Entities;

namespace My.Ddd.Domain
{
    public class MyBaseAggregates<TKey> : BasicAggregateRoot<TKey>, IMyAudit
    {

        public MyBaseAggregates()
             : base(SequentialIdProviderFactory.GetProvider<TKey>().GenerateId())
        {

        }


        /// <summary>
        /// 删除时间
        /// </summary>
        public DateTime? DeletionTime { get; set; }

        /// <summary>
        /// 是否删除
        /// </summary>
        public bool IsDeleted { get; set; }

        /// <summary>
        /// 修改时间
        /// </summary>
        public DateTime? LastModificationTime { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreationTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 创建人
        /// </summary>
        public string CreatorId { get; set; }

        /// <summary>
        /// 修改人
        /// </summary>
        public string LastModifierId { get; set; }

        /// <summary>
        /// 删除人
        /// </summary>
        public string DeleterId { get; set; }

        [Timestamp]
        public byte[] Timestamp { get; set; }
    }

    public class MyBaseLongAggregates : MyBaseAggregates<long>
    {

    }


    public interface IMyAudit : IHasCreationTime, IHasModificationTime, IHasDeletionTime
    {


    }


    public class MyEntity : Entity<long>, IMyAudit
    {
        protected MyEntity()
            : base(SequentialIdProviderFactory.GetProvider<long>().GenerateId())
        {
        }


        public DateTime CreationTime { get; set; }
        public DateTime? LastModificationTime { get; set; }
        public bool IsDeleted { get; set; }
        public DateTime? DeletionTime { get; set; }
        public string CreatorId { get; set; }
        public string LastModifierId { get; set; }
        public string DeleterId { get; set; }
    }
}
